void main() {
  var s = new Student();
  s.name = "张三";
  s.age = 20;
  s.school = "清华大学";
  s.major = "计算机科学与技术";
  s.eat();

  print({s.name, s.age, s.school, s.major});
  s.study();

  var t = new Teacher();
  t.name = "李四";
  t.age = 30;
  t.school = "北京大学";
  t.major = "数学";
  t.title = "教授";
  t.eat();
  print({t.name, t.age, t.school, t.major, t.title});
  t.work();

// 通过mixin扩展的方法

  t.eatFood("苹果", "李四");
}

class Person {
  String? name;
  int? age;

  eat() {
    print("${this.name}正在吃饭");
  }
}

class Student extends Person {
  String? school; //学校
  String? major; //专业

  void study() {
    print("${this.name}正在学习");
  }
}

class Teacher extends Person with Food {
  String? school; //学校
  String? major; //专业
  String? title; //职称

  void work() {
    print("${this.name}正在工作");
  }
}

//mixin 混入 (解耦)
mixin Food {
  String? food;

  void eatFood(String food, String name) {
    print("$name 正在吃$food");
  }
}
